home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 2: CDPD 1 / Almathera Ten on Ten - Disc 2: CDPD 1.iso / pd / 101-125 / 118 / hammmm / mmm_control < prev    next >
Text File  |  1995-03-13  |  2KB  |  88 lines

  1. \ Top level control of HAMmmm program which
  2. \ demonstrates Amiga HAM graphics, double buffering,
  3. \ and local sound.
  4. \
  5. \ Author: Phil Burk
  6. \ Copyright 1987 Phil Burk
  7. \ This code is considered to be in the public domain and
  8. \ may be freely distributed but may not be sold for profit.
  9.  
  10. ANEW TASK-MMM_CONTROL
  11.  
  12. : HAM.CHECK.EVENTS { | rmessage mcode -- , process any events }
  13. \ Check for an IntuiMesssage
  14.     gr-curwindow @ ..@ wd_userport call exec_lib GetMsg ?dup
  15.     IF  >rel -> rmessage
  16.         rmessage ..@ im_code -> mcode
  17.         rmessage ..@ im_class
  18.         rmessage >abs call exec_lib ReplyMsg drop
  19.         CASE
  20.             MENUPICK
  21.             OF  mcode dup MENUNULL =
  22.                 IF drop ham.continue  ( restart graphics )
  23.                 ELSE control-menu ezmenu.exec ( DO MENU! )
  24.                 THEN
  25.             ENDOF
  26. \
  27. \ Make sure double buffering is turned off because it would
  28. \ make the menus flash.
  29.             MENUVERIFY  
  30.             OF  ham-enable-graphics off
  31.             ENDOF
  32.         ENDCASE
  33.     THEN
  34. ;
  35.     
  36. : HAM.LOOP ( -- , Create drawings until key hit. )
  37.     false ham-demo-quit !
  38.     BEGIN
  39.         ham-enable-graphics @
  40.         IF  ham.moving.lines
  41.             change.sound
  42.         THEN
  43.         ham.check.events
  44.         ?terminal ham-demo-quit @ or
  45.     UNTIL
  46. ;
  47.  
  48. \ Seed the random number generator with the current time
  49. \ so that HAMmmm will always produce different animation.
  50. variable CLOCK-BUFFER 8 allot
  51. : TIME@ ( -- time )
  52.     clock-buffer >abs call dos_lib datestamp drop
  53. ( demonstrate brute force method for accessing structure )
  54.     clock-buffer 4 + @ 3000 * ( minutes )
  55.     clock-buffer 8 + @ +      ( ticks )
  56. ;
  57.  
  58. : RANDOM.INIT ( -- , seed random number generator with time )
  59.     time@ rand-seed !
  60. ;
  61.  
  62. : HAM.INIT  ( -- , Initialize HAMmmm system )
  63.     ham.open
  64.     ham.set.colors
  65.     random.init
  66.     ham.setup.pos
  67.     ham.setup.vel
  68.     buffers.init
  69.     ham.menu.init
  70.     sound.init
  71.     ham-enable-graphics on
  72. ;
  73.  
  74. : HAM.TERM ( -- , Cleanup afterwards. )
  75.     ham.menu.term
  76.     sound.term
  77.     buffers.term
  78.     ham.close
  79. ;
  80.  
  81. : HAMmmm  ( -- , top word of demo, does all )
  82.     ham.init
  83.     ham.loop
  84.     ham.term
  85. ;
  86.  
  87. cr ." Enter:     HAMmmm     to see demo!" cr
  88.